require("Container")

Content = class("Content", Container)

---

function Content:initialize(name, type)

	if not type 
	then
		type = "Content"
	end
	
	Container.initialize(self, name, type)

	self:registerEntityType("Content")
	
	self:addProperty("CurrentContainer")
	
	self.currentContainerCollapseBeat = -1
end

---

function Content:isIn(location)

	--gLogger:log("Check if " .. self.type .. " " .. self.name .. " is collasped in Container " .. location.name)
	
	return
	(
		self:isPropertyCollasped("CurrentContainer") and
		self.CurrentContainer[location]
	) 
end

---

function Content:isPotentialyIn(container)

	--gLogger:log("Check if " .. self.type .. " " .. self.name .. " is potentialy in Location " .. container.name)
	
	return self.CurrentContainer[container]
end

---

function Content:observe(observedContainer)

	if self:reduceProperty("CurrentContainer", observedContainer)
	then
		self.currentContainerCollapseBeat = gField.beat
	end
		

	-- observe the other properties if current location is collasped in observed location

	if 
		self:isPropertyCollasped("CurrentContainer") and
		(self:getCollapsedProperty("CurrentContainer") == observedContainer) 
	then
		Entity.observe(self)
	end
end